/**
 * This file is a part of qloudgen-sec. 
 * You can redistribute qloudgen-sec and/or modify it under the terms of the Lesser GNU General Public License version 3. 
 * qloudgen-sec is distributed WITHOUT ANY WARRANTY. 
 *
 * See the Lesser GNU General Public License for more details at http://www.gnu.org/licenses/. 
 **/
package org.qloudgen.sec.cas.server.ticket.registry;

import java.util.List;
import java.util.Collection;

import org.jasig.cas.ticket.Ticket;

import org.qloudgen.sec.cache.Cache;
import org.qloudgen.sec.cache.CacheManager;
import org.qloudgen.sec.cache.redisson.ClusterCacheImpl;

/**
 * <p>Title: Cached Tickets Registry</p>
 * <p>Description: Wrapper redis cluster cached tickets registry implementation.</p>
 * <p>Copyright: qloudgen/sec 2014</p>
 * @author <a href="mailto:hyq.dd.sun@gmail.com">glue.3M</a>
 */
public class RedisClusterCachedTicketRegistry extends CachedTicketRegistry {
	/**
	 * Custom constructor.
	 *
	 * @param cacheManager
	 */
	public RedisClusterCachedTicketRegistry(CacheManager cacheManager) {
	    super( cacheManager );
	}
	
	/**
	 * Custom constructor.
	 *
	 * @param cacheManager
	 */
	public RedisClusterCachedTicketRegistry(CacheManager cacheManager , String cacheName) {
	    super( cacheManager , cacheName );
	}

	/**
	 *
	 *
	 * @return List<String>
	 */
	public List<String> getTickets(int num , long cursor , String pattern , long count) {
		ClusterCacheImpl<String, Ticket> _tickets = ( ClusterCacheImpl )cacheManager.getCache( cacheName );
		return _tickets.keys( num , cursor , pattern , count );
	}

	/**
	 * @see org.jasig.cas.ticket.registry.AbstractTicketRegistry
	 *
	 * @return Collection<Ticket>
	 */
	@Override
	public Collection<Ticket> getTickets() {
		throw new RuntimeException( "Redis cluster will not support map.values operation." );
	}
}